_package("caf.ui");

_import("alz.core.Animation");
_import("alz.mui.Component");
_import("caf.ui.Button");
/**
 * 滚动条组件
 */
_class("ToolBar", Component, function(){
	this._init = function(){
		_super._init.call(this);
		this._animation = null;
		this._conf = null;
		this._btn = null;
		
	};
	this.create = function(parent){
		//var obj = this.createElement(parent, "div", "scrollbar");
		//this.init(obj);
		//return obj;
	};
	this.bind = function(obj, conf){
		this._conf =conf;
		console.log(this._conf);
		this.setParent(conf.parent);
		if(conf.id){
			this.setId(conf.id);
		};
		//this._conf =conf;
		
		this.init(obj);
	};
	this.init = function(obj){
		_super.init.apply(this, arguments);
		this._self.innerHTML="<span class='title'>"+this._conf.title+"</span>";
		if(this._conf.button){
			var _btn = this.parseTag(this._conf.button);
			this._btn = new Button(_btn.id,_btn.text,_btn.dock);
			this._btn.create(this._self);
		}

	};
	this.dispose = function(){
		_super.dispose.apply(this);
	};
	this.parseTag = function(str){
		var conf = {};
		var _str = str.replace(/{/,"").replace(/}/,"");		
		var arr = _str.split(",");
		for(var i = 0, len = arr.length; i < len; i++){
			var a = arr[i].split(":");
			conf[a[0]] = a[1];
		}
		//console.log(conf)
		return conf;
	};
	
});